<?php
class core {
var $db,$page;	
	

function __construct()
{
$this->_init_autoload();
}



function load_lib($lib_name)
{
static $loaded_lib=array();


if(is_array($lib_name) && count($lib_name)>0){
	foreach ($lib_name as $item) {
	//echo $item;	
	$this->load_lib($item);
	}
	return;
}

if(isset($loaded_lib[$lib_name])) return;
	

	
$this->$lib_name=new $lib_name;
$loaded_lib[$lib_name]=$lib_name;	
	
}

private function _init_router()
{
$c=$_GET['c'];
$a=$_GET['a'];

if(empty($c)) $c='home';
if(empty($a)) $a='index';

$file=BASE_PATH.'web/controller/'.$c.'_controller.php';
if(!is_file($file)) {
	die('Not Found Controller:'.$file);
}else {
	require $file;
}

if(!class_exists($c)){
	die('Not Found Controller Class:'.$c);
} else {
	$c=new $c();
}


if(method_exists($c, $a)) {
	$c->$a();
} else {
	die('Not Found Medthod:'.$a);
}


}


function init()
{

$this->_init_router();

//print_array($this);
}


private function _init_autoload()
{
$autoload=config::get_item('autoload');	
if(count($autoload)>0){
	foreach ($autoload as $item){
		//echo $item;
		$this->$item=new $item();
	}
}

}








	
}